<?php 
/* Template Name: Parques e Zoos */

$post = $wp_query->post;
get_header();
?>



<style type="text/css">
.cont-logo-parque-zoo {margin: auto; display: table;}
.cont-outra-info {width: 400px; height: auto; margin: auto; display: table;}
.gmap3 {margin: 20px auto; border: 1px dashed #C0C0C0; width: 195px; height: 125px;}

</style>		

<div class="cont-topo">		
	<div class="bar-page" style="border-bottom: 2px #efefef solid;"><?php conteudo_barra_page ('Link direto:&nbsp;'); ?></div>
	<div class="vertical_space_20"></div>		
	<div class="bar-page"><?php titulo_barra_page ('Parques & Zoos', get_the_title()); ?></div>
	<div class="vertical_space_20"></div>
</div><!-- Fim div conteiner-topo -->

<div class="cont-miolo">
	<?php 		
	include_once TEMPLATEPATH.'/av-define.php';
	include_once PDO.'/NextGenPDO.class.php';
	$ng = new NextGenPDO ();
	$linha = $ng->galeria_id_by_author($post->post_author);		// gid, name, previewpic, author - gallery
	$galeria_picture_tudo = $ng->galeria_get_picture_source();	// filename, path, gid, author, name - gallery_pictures
	?>

	<div class="cont-logo-parque-zoo">
		<?php
		if (have_posts()) : 
			while (have_posts()) : the_post();
				the_thumb();       		
   			endwhile; 
			endif; 
			?>
 	</div>
	<div class="clr"></div>	
	<div class="vertical_space_20"></div>

	<?php
	// ================================================================================================================================	
	// Insere balão de diálogo com as espécies que o criador cria
	if ( get_post_meta($post->ID, 'avpt_parques_zoos_descricao', true) ) { ?>
	    <div class="cont-balao ">
	    	<?php 
	    	do_dialog_baloon(get_post_meta($post->ID, 'avpt_parques_zoos_descricao', true), 
	    		'parques-zoos', 
	    		get_post_meta($post->ID, 'avpt_parques_zoos_nome', true)); 
	    	?>
	    </div>
		<div class="clr"></div>
    <?php
	}
	// ================================================================================================================================	    	
	?>
	<div class="vertical_space_30"></div>

	<?php
	// ================================================================================================================================	
	// Verifica se há galeria de fotos de aves do criador, se sim mostra, do contrário oculta está área	
	// ================================================================================================================================
	if ( $linha != 0 ) { 
    	foreach ($linha as $key => $value) { 
    		$no_space_park_name = str_replace(' ', '', $value['name']);
			$no_space_title = retira_acentos(strtolower(str_replace(' ', '', get_the_title())));					
    		if ( strcmp($no_space_park_name, 'parques-zoos-'.$no_space_title) == 0  && $value['previewpic'] != 0 ) { ?>
		    	<div class="cont-carrossel"> 
			    	<script type="text/javascript">
						$(document).ready(function() {
							$('.slider1').bxSlider( {
							    slideWidth: 130,
							    minSlides: 4,
							    maxSlides: 4,
							    slideMargin: 10,
							    controls: true,
							    pager: false
						    });
						});
					</script>
					<style type="text/css">
					.bx-wrapper {
					    margin: 0 auto 10px;
					    padding: 0;
					    position: relative;
					}
					</style>
					<div style="width: 610px; float: right; font-size: 24px;">Fotos</div>
					<div class="vertical_space_40"></div>
					
					<div class="slider1"> 
						<?php								  	
					  	//Quantidade de fotos da galeria
					  	$aux_qtde_pictures = 0; 
				  		foreach ($galeria_picture_tudo as $key => $value) {
				  			if ( strcmp($no_space_park_name, 'parques-zoos-'.$no_space_title) == 0) {
				  				$aux_qtde_pictures = $aux_qtde_pictures + 1;
				  				$fotos [] = $value;
				  			}		  			
				  		}
				  		$aux_grade = 0;
				  		foreach ($fotos as $key => $value) {
				  			$aux_grade = $aux_grade + 1;
				  			if ( eh_par($aux_grade) == 0 ) { ?>
				  				<div class="slide">
							  		<a href="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>">
										<img src="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>" width="198px" height="96px" style="margin-bottom: 10px;" />
									</a>
				  			<?php
				  			} else { ?>
					  				<a href="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>">
										<img src="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>" width="198px" height="96px" />
									</a>
								</div><!-- Fim div slide-->
				  			<?php
				  			}
				  			if ( eh_par($aux_qtde_pictures) == 0 && ($aux_qtde_pictures - 1 == $aux_grade) ) {
				  				break;
				  			}								  								  			
				  		}
						?>
					</div><!-- Fim div slide1-->
				</div>	
				<?php
			}	
    	}
    }
	// ================================================================================================================================
	?>
	<div class="vertical_space_30"></div>
	
	<div class="cont-outra-info">
		<br /></br>
		<div style="width: 610px; float: right; font-size: 24px;">Outras Informações</div>
		<br /></br><br />
		<span class="azul18">Título</span>
		<br /><br />
		<span class"preto16"><?php echo get_post_meta($post->ID, 'avpt_parques_zoos_outras_info', true); ?></span>
 	</div>
	<div class="clr"></div>	

	<div class="vertical_space_30"></div>

</div><!-- Fim div cont-miolo -->


<div class="cont-direita">



	<?php
	// ================================================================================================================================
	// Bloco contatos: Mostra os seguintes itens do criador: Email, telemóvel e página web do criador 
	// ================================================================================================================================		
	?>
	<div class="cont-contatos">
		<div style="margin-left: 10px;"><span class="preto24">Sobre ...</span></div>
		<div class="vertical_space_15"></div>
		<ul style="list-style-type: none; padding: 0; margin: 0 0 0 10px;">
			<li>
				<div style="float: left;"><img alt="" src="<?php echo bloginfo('template_directory')?>/images/icon/laptop.png" width="20" height="20" /></div>
				<div style="float: left; width:90%;"><span class"preto16">&nbsp;Página web</span></div>
				<br />
				<span class="azul16"><a href="<?php echo get_post_meta($post->ID, 'avpt_parques_zoos_end_web', true);?>" target="_blank">&nbsp;<?php echo get_post_meta($post->ID, 'avpt_parques_zoos_end_web', true); ?></a></span>
			</li>
			<li style="border-bottom: 2px solid #efefef;"> &nbsp; </li>
			<?php 
			if ( get_post_meta($post->ID, 'avpt_parques_zoos_endereco', true) ) { ?>
				<li>
					<br />
					<div style="float: left;"><img alt="" src="<?php echo bloginfo('template_directory')?>/images/icon/home.png" width="20" height="20" /></div>
					<div style="float: left; width:90%;"><span class="preto16">&nbsp;Localização</span></div>
					<br />
					<span class="azul16"><?php echo get_post_meta($post->ID, 'avpt_parques_zoos_endereco', true);?></span>
			    </li>
			    <li>
			    	<?php $variavel = preg_replace('/\s/',' ',get_post_meta($post->ID, 'avpt_parques_zoos_endereco', true)); ?>
			    	<script type="text/javascript">
			    	var variavel = new Array();
					variavel['teste'] = "<?=$variavel;?>";
    				$(function(){
    					$('#mapa').gmap3({
 							map: {
    							options: {
    								maxZoom: 18
    							}  
 							},
 							marker:{
    							address: variavel['teste']
    						}
						},
						"autofit");
   	 				});
    				</script>  
    				<div id="mapa" class="gmap3"></div>
			    </li>	
			    <li style="border-bottom: 2px solid #efefef;"> &nbsp; </li>
			<?php 	
			}						
			if ( get_post_meta($post->ID, 'avpt_parques_zoos_contactos', true) ) { ?>
				<li>
					<br />
					<div style="float: left;"><img alt="" src="<?php echo bloginfo('template_directory')?>/images/icon/telephone.png" width="20" height="20" /></div>
					<div style="float: left; width:90%;"><span class="preto16">&nbsp;Contactos</span></div>
					<br />
					<span class="azul16">&nbsp;<?php echo get_post_meta($post->ID, 'avpt_parques_zoos_contactos', true);?></span>
			    </li>
			    <li style="border-bottom: 2px solid #efefef;"> &nbsp; </li>
			<?php 	
			}
			if ( get_post_meta($post->ID, 'avpt_parques_zoos_email', true) ) { ?>
				<li>
					<br />
					<div style="float: left;"><img alt="" src="<?php echo bloginfo('template_directory')?>/images/icon/email.png" width="20" height="20" /></div>
					<div style="float: left; width:90%;"><span class="preto16">&nbsp;Email</span></div>
					<br />
					<span class="azul16">&nbsp;<?php echo get_post_meta($post->ID, 'avpt_parques_zoos_email', true);?></span>
			    </li>
			    <li style="border-bottom: 2px solid #efefef;"> &nbsp; </li>
			<?php 	
			}
			if ( get_post_meta($post->ID, 'avpt_parques_zoos_horario', true) ) { ?>
				<li>
					<br />
					<div style="float: left;"><img alt="" src="<?php echo bloginfo('template_directory')?>/images/icon/calendar.png" width="20" height="20" /></div>
					<div style="float: left; width:90%;"><span class="preto16">&nbsp;Horário</span></div>
					<br />
					<span class="azul16">&nbsp;<?php echo get_post_meta($post->ID, 'avpt_parques_zoos_horario', true);?></span>
			    </li>
			    <li style="border-bottom: 2px solid #efefef;"> &nbsp; </li>
			<?php 	
			}
			if ( get_post_meta($post->ID, 'avpt_parques_zoos_tarifario', true) ) { ?>
				<li>
					<br />
					<div style="float: left;"><img alt="" src="<?php echo bloginfo('template_directory')?>/images/icon/euro.png" width="20" height="20" /></div>
					<div style="float: left; width:90%;"><span class="preto16">&nbsp;Tarifário</span></div>
					<br />
					<span class="azul16">&nbsp;<?php echo get_post_meta($post->ID, 'avpt_parques_zoos_tarifario', true);?></span>
			    </li>
			    <li style="border-bottom: 2px solid #efefef;"> &nbsp; </li>
			<?php 	
			}
			?>			
		</ul>
	</div>
	<div class="clr"></div>
	<div class="vertical_space_20"></div>
	<?php
	// ================================================================================================================================

	// ================================================================================================================================		
	// Bloco contatos 2: Mostra outros itens do criador: localidade, modalidade, federação, identificação e licença 
	// ================================================================================================================================		
	?>
	<div class="cont-criador">
		<div style="margin-left: 10px;"><span style="<?php fonte_cor('preto24');?>">Criador</span></div>
		<div class="vertical_space_15"></div>
		<?php
		load_bloco_criador_sobre ( get_user_meta($user_info->ID, 'concelho', true), 
			get_user_meta($user_info->ID, 'modalidade', true), 
			get_user_meta($user_info->ID, 'clube', true), 
			get_user_meta($user_info->ID, 'clube2', true), 
			get_user_meta($user_info->ID, 'clube3', true), 
			get_user_meta($user_info->ID, 'stam', true), 
			get_user_meta($user_info->ID, 'licenca', true) ); ?>
	</div><!-- Fim div cont-criador -->
	<div class="clr"></div>
	<div class="vertical_space_40"></div>
	<?php
	// ================================================================================================================================

	// ================================================================================================================================		
	// Verifica se vieram dados do formulário de contato, se sim dispara email
	// ================================================================================================================================		  
	if (isset($_POST["from_form"])) {			
		$from_form = $_POST["from_form"]; 			
		if ( $from_form == 1 ) {
			if (isset($_POST["message"]))    {$internauta_mensagem = $_POST["message"];}
			if (isset($_POST["nome"]))       {$internauta_nome = $_POST["nome"];}
			if (isset($_POST["telefone"]))   {$internauta_telefone = $_POST["telefone"];}
			if (isset($_POST["email"]))      {$internauta_email = $_POST["email"];}
			if (isset($_POST["email_copy"])) {$internauta_email_copia = $_POST["email_copy"];}
			if (isset($_POST["email_dest"])) {$internauta_email_destinatario = $_POST["email_dest"];}
			//Prepara e envia email
			$email_destinatario  = $internauta_email_destinatario;
			$email_assunto       = '[AVES PT] Contato internauta';
			$internauta_mensagem = $internauta_nome. ' Recomenda: ' .url_atual(). '<br /><br />'. $internauta_mensagem;
			if ( $internauta_email_copia != 1 ) {
				$internauta_email_copia = 0;
				envia_email ( $internauta_email, $email_destinatario, 
					$internauta_nome, $internauta_telefone, $internauta_mensagem, $email_assunto, $internauta_email_copia);
			} else {
				envia_email ( $internauta_email, $email_destinatario, 
					$internauta_nome, $internauta_telefone, $internauta_mensagem, $email_assunto, $internauta_email_copia);
			}
		}			
	}
	// ================================================================================================================================

	// ================================================================================================================================		
	// Bloco Formulário para contactar criador e indicar a página para outros internautas
	// ================================================================================================================================
	load_form_email();
	?>
	<div class="vertical_space_20"></div>
	<div class="clr"></div>
	<div class="vertical_space_50"></div>
	<?php
	// ================================================================================================================================
	?>

</div><!-- Fim div cont-direita -->


<div class="cont-direitos" style="border-top: 2px #efefef solid;">
	<?php direito_barra_page ("Página de detalhes do ", get_the_title()); ?>
</div>

</div><!-- Fim div corpo -->
<div class="vertical_space_20"></div>

<div class="cont-miolo-pub"><?php add_google_pub_bloco_2x468x60 (); ?></div>
<div class="vertical_space_20"></div>

</div><!-- Fim div tudo -->

<?php get_footer(); ?>

</body>

</html>